package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.domain.db.UserInfo;
import com.tanhua.dubbo.mapper.UserInfoMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class UserInfoApiImpl implements UserInfoApi {
    @Autowired
    private UserInfoMapper userInfoMapper;

    @Override
    public void save(UserInfo userInfo) {
        userInfoMapper.insert(userInfo);
    }

    @Override
    public void update(UserInfo userInfo) {
        userInfoMapper.updateById(userInfo);
    }

    @Override
    public UserInfo findById(Long userId) {
        return userInfoMapper.selectById(userId);
    }

    @Override
    public IPage<UserInfo> findList(int page, int pagesize) {

        return userInfoMapper.selectPage(new Page<>(page, pagesize), null);
    }

    @Override
    public List<UserInfo> find() {
        return userInfoMapper.selectList(null);
    }



    @Override
    public List<UserInfo> randomInfo(int i) {
       List<UserInfo> userInfoList =  userInfoMapper.randomInfo(i);
        return userInfoList;
    }
}
